﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AnalisisDeRiesgosConfiguration.Controller;
using AnalisisDeRiesgosConfiguration.Model;

namespace AnalisisDeRiesgosConfiguration
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnConfigure_Click(object sender, EventArgs e)
        {
            try
            {
                RegisterDataController controller = new RegisterDataController(textBoxRootPassword.Text, textBoxUrl.Text);

                controller.ExecuteScript(textBoxUserDB.Text);
                controller.RegisterUser(new User
                {
                    CI = textBoxCI.Text,
                    FirstName = textBoxFirstName.Text,
                    LastName = textBoxLastName.Text,
                    Password = textBoxPassword.Text,
                    RePassword = textBoxRePassword.Text,
                    SecondLastName = textBoxSecondLastName.Text
                });
                controller.RegisterManagement(new Management
                {
                    Name = textBoxManagementName.Text,
                    CI = textBoxCI.Text
                });
                MessageBox.Show("La configuracion fue realizada con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}
